$(function () {
  //初始化提示工具
  var nav_tabs = $('.wrapper > .nav-tabs');
  var lis = nav_tabs.find('li');
  $('[data-toggle="tooltip"]').tooltip();
  var items = $('.carousel-inner .item');
  $(window).on('resize', function () {
    var width = $(window).width();
    if (width>=768) {
      $(items).each(function (index,value) {
        var item = $(this);
        var srcImg = item.data('largeImage');
        item.html($('<a href="javascript:;" class="pcImg"></a>')).children(0).css("background-image","url("+srcImg+")")
      })
    }else {
      $(items).each(function(index,value){
        var item = $(this);
        var srcImg = item.data('smallImage');
        item.html('<a href="javascript:;" class="mobelimgBox"><img src="'+srcImg+'"></a>');
      })
    }
  }).trigger("resize");

//  轮播图手动轮播
  var carousel_inner = document.querySelector('.carousel-inner')
  var startX = 0;
  var endX= 0;
  var carousel = $('.carousel');
  carousel_inner.addEventListener('touchstart',function(e){
    startX = e.targetTouches[0].clientX;
  })
  carousel_inner.addEventListener('touchend',function(e){
    endX = e.changedTouches[0].clientX;
    if(endX - startX > 0){
      carousel.carousel('prev');
    }else if(endX - startX < 0){
      carousel.carousel('next');
    }
  })
  var totalWidth = 100;
  var wrapper = $('.wrapper');
  lis.each(function(i,e){
    totalWidth += $(e).outerWidth(true);
  })
  nav_tabs.width(totalWidth)

  var myScroll = new IScroll('.wrapper',{
    scrollX:true,
    scrollY:false
  });

  //获取所需要的元素
  // var jdCateLeft=document.querySelector('.jd_cateLeft');
  //取消事件默认动作
  nav_tabs.get(0).addEventListener('touchmove',function(e){
    e.preventDefault();
  });

})